#include "widget.h"
#include "ui_widget.h"
#include"QPushButton"
#include"QIcon"
#include"QRect"
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
//    QPushButton* btn=new QPushButton(this);

//    QIcon icon(":/OIP-C.jfif");//创建图标
//    btn->setIcon(icon);//给按钮设置图标
//    btn->setIconSize(QSize(64,64));//隐式构造，设置图标尺寸
//    btn->setEnabled(true);//设置按钮是否启用
//    //btn->setShortcut(QKeySequence("s"));//自定义快捷键控制按键
//    btn->setShortcut(Qt::CTRL+Qt::Key_Space);//系统自带的关键字组合控制按键，ctrl不能单独控制

     ui->pushButton_target->setIcon(QIcon(":/gu.png"));
     ui->pushButton_target->setIconSize(QSize(64,64));
     ui->pushButton_up->setIcon(QIcon(":/chevron-up.png"));
     ui->pushButton_target->setIconSize(QSize(64,64));
     ui->pushButton_down->setIcon(QIcon(":/chevron-down.png"));
     ui->pushButton_target->setIconSize(QSize(64,64));
     ui->pushButton_right->setIcon(QIcon(":/chevron-right.png"));
     ui->pushButton_target->setIconSize(QSize(64,64));
     ui->pushButton_left->setIcon(QIcon(":/chevron-left.png"));
     ui->pushButton_target->setIconSize(QSize(64,64));
     ui->pushButton_left->setAutoRepeat(true);//设置按住不松连续控制


}

Widget::~Widget()
{
    delete ui;
}



void Widget::on_pushButton_up_clicked()
{
    QRect rect=ui->pushButton_target->geometry();
    ui->pushButton_target->setGeometry(rect.x(), rect.y() - 5, rect.width(),
                                       rect.height());

}

void Widget::on_pushButton_left_clicked()
{
    QRect rect=ui->pushButton_target->geometry();
    ui->pushButton_target->setGeometry(rect.x()-5, rect.y(), rect.width(),
                                     rect.height());
}

void Widget::on_pushButton_down_clicked()
{
    QRect rect = ui->pushButton_target->geometry();
    ui->pushButton_target->setGeometry(rect.x(), rect.y() + 5, rect.width(),
   rect.height());
}

void Widget::on_pushButton_right_clicked()
{
    QRect rect = ui->pushButton_target->geometry();
    ui->pushButton_target->setGeometry(rect.x() + 5, rect.y(), rect.width(),
   rect.height());
}
